//var InitURL = getInitUrls();

/**
 * 收藏弹窗相关
 */
/*收藏网站按钮*/
//var auth_uid = cookie('auth_id');
var auth_uid = $('.collect-icon').text();
var webCollectBt = $('.web-collect-wrap .collect-bt');
$('.collect-icon').click(function(){
    $('.collect-icon').attr('status',1);
    $.getJSON("http://ajax.ibaotu.com/?m=collectionWeb&auth_uid="+auth_uid+"&type=1&callback=?", function(e) {});
    webCollectBt.show();
    setTimeout(function(){
        webCollectBt.hide();
    }, 4000)
});
/**
 * 判断下载权限
 */
function showGG() {
	$.ajax({
		url: '/plus/chaxunlogin.php',
        //data: {},
        dataType: 'json',
        success:function(r){
		   if(r.status==0){
			    _login('登录网站', '登录后查看权限');
		        return false;
           }else if(r.status==1){

	           //获取文档收藏状态
	           var id = $('.shoucangxiangqing').attr('data-id');
               var data = {aid:id};
               $.ajax({
		            url: '/plus/xzqx.php',
                    data : data,
                    dataType: 'json',
                    success:function(r){
		                if(r.status == 0){
		                     $('.login-pop').show();
		                }else {
			                 $('#msg').html(r.msg);
			                 $('#anniu').html(r.anniu);
			                 $('#noVipPop').show();
			                  //alert(r.msg)
                        }
	                 }

               })	 
            }else{
			    $('#msg').html('系统错误');
			    $('#anniu').html(r.anniu);
			    $('#noVipPop').show(); 
			}
		}
	})
}
/**
 * 收藏ctrl+d操作
 */
$(document).keydown(function(e){
    if(e.ctrlKey && e.which == 68)
    {
        triggerSomething();
    }
});
function triggerSomething()
{
    if ($('.collect-icon').attr('status') == 1) {
        $.getJSON("http://ajax.ibaotu.com/?m=collectionWeb&auth_uid="+auth_uid+"&type=2&callback=?", function(e) {});
    }
}
/**
 * 关闭弹窗
 */
$('.collect-bt>a').click(function(){
    webCollectBt.hide();
});
/*
 * 登录JS
 */
 function toLogin(){
    var iWidth = 750;
    var iHeight = 500;
    var iTop = (window.screen.availHeight - 30 - iHeight) / 2;
    var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;
    window.open("/index.php?m=login&a=snsLogin&type=qq","","width="+iWidth+", height="+iHeight+", top="+iTop+", left="+iLeft);
}
/*
 * zxc
 */
$(function() {
	
	var $nowThis = $('.bt-sort a');
    function nowThis(divName, clName) {
        divName.click(function() {
            $(this).addClass(clName).siblings().removeClass(clName);

        })
    }
    nowThis($nowThis, 'nowthis-color');
    //获取文档收藏状态
	var id = $('.shoucangxiangqing').attr('data-id');
    var status = $('.shoucangxiangqing').attr('data-status');
    var data = {aid:id};
    $.ajax({
		url: '/plus/sczt.php',
        data : data,
        dataType: 'json',
        success:function(r){
		//alert(r.status)
		   if(r.status == 0){
		       $('.shoucangxiangqing').removeAttr('id');
		       $('.shoucangxiangqing').attr("data-status","0");
		   }else if(r.status == 1){
			   $('.shoucangxiangqing').attr('id','collected');
			   $('.shoucangxiangqing').attr("data-status","1");
           }
	    }
	})
	//记录浏览内容
	var id = $('.shoucangxiangqing').attr('data-id');
    var status = $('.shoucangxiangqing').attr('data-status');
    var data = {aid:id};
    $.ajax({
		url: '/plus/jilu.php',
        data : data,
        dataType: 'json',
        success:function(r){
		//alert(r.status)
		   if(r.status == 0){
		       $('.shoucangxiangqing').removeAttr('id');
		       $('.shoucangxiangqing').attr("data-status","0");
		   }else if(r.status == 1){
			   $('.shoucangxiangqing').attr('id','collected');
			   $('.shoucangxiangqing').attr("data-status","1");
           }
	    }
	})
	
	//高亮处理
	var geshu = $('#gaoliang a').length
	var goliangyi = $('#gaoliang').find('a:eq(2)').text();
		var golianger = $('#gaoliang').find('a:eq(3)').text();
	//alert(geshu)
	if(geshu == 4){
	    $("#diyiji div a:contains(全部)").removeClass('active');
		$("#dierji div a:contains(全部)").removeClass('active');
	    $("#diyiji div a:contains('" + goliangyi + "')").addClass('active');
		$("#dierji div a:contains('" + golianger + "')").addClass('active');
	}else{
		$("#diyiji div a:contains('" + goliangyi + "')").addClass('active');
		$("#dierji div a:contains(全部)").addClass('active');
	}
    //alert(quzhi)
	
	//统计会员总数
    $.ajax({
		url: '/plus/tjhy.php',
        //data : data,
        dataType: 'json',
        success:function(r){
		   if(r.status == 1){
		       $('.tongjihuiyuan').text(r.zongshu);
		   }
	    }
	})
	//获取会员类型
    $.ajax({
		url: '/member/huiyuanleixing.php',
        //data : data,
        dataType: 'json',
        success:function(r){
		   if(r.status == 1){
		       $('.viptishi').text(r.msg);
			   $('.huiyuantubiao').attr("src", "/revision/img/mascot_sad.png");
		   }else{
			   $('.viptishi').text(r.msg);
			   $('.huiyuantubiao').attr("src", "/revision/img/mascot_happy.png");
			   $('#kaitonganniu').hide();
		   }
	    }
	})
	// 收藏图标切换
	$('.icon-shoucang1').click(function() {
		var $this = $(this);
		collected($this);
	});
	if ( $(".collect-wrap>.icon-shoucang1").length > 0 ) {
		$('.collect-wrap').click(function() { // 针对详情页大收藏图标
			var $this = $(this).find('i');
			collected($this);
		});
		$('.collect-wrap>.icon-shoucang1').unbind('click');
	} 
	function collected(s) {
		var auth_uid = $('.baotu-id').text();
		//alert(auth_uid)
		if(auth_uid == ""){
			_login('登录网站', '登录后可收藏');
			return false;
		}
		var $this = s;
		var id = parseInt($this.attr('data-id'));
		var title = $('.works-name').text();
        var status = parseInt($this.attr('data-status'));
        var data = {aid:id,status:status,title:title};
		var tips = $('.collect-tips');   	   
        //收藏埋点end
		tips.hide();
        $.ajax({
            url: '/plus/sc.php',
            data : data,
            dataType: 'json',
            success:function(r){
                if(r.status == 1){
					var random = Math.random();
					tips.attr('flag',random);
                    if(status == 0){
						$this.attr('id','collected');
						$this.attr("data-status","1");
						tips.html('收藏成功');
						tips.fadeIn(200);
                    }else if(status == 1){
						$this.removeAttr('id');
						$this.attr("data-status","0");
						tips.html('取消成功');
						tips.fadeIn(200);
                    }
					setTimeout(function(){
						if(tips.is(':visible') && tips.attr('flag')==random){
							tips.hide();
						}
					},1500);
                }
            }
        })
	}
    var length = $(".video-box").length;
    $('.video-box').hover(function() {
        $(this).find("img").hide();
        $(this).find("video").get(0).play();
        $(this).find("video").attr("loop", "loop");
    }, function() {
        $(this).find("img").show();
        $(this).find("video").get(0).pause();
    })
})
/*
 * 公用页面操作 
 */
var qWindowHeight = $(window).height();
var classifyHeadInp = $('.pb-head-classify .head-classify-inp');
var officeTopInp = $('.search-wrap .head-classify-inp');
var beijinTopInp = $('.beijing-class');
var floadHeadInp = $('.float-search-input .head-classify-inp');
var homeTopInp = $('.home-search-wrap .home-search-inp');
var adCrumbsInp = $('.crumbs-labels .search-wrap>input');
var searchInp = $('.float-search-input .search-head-classify-inp');
//回到顶部
backToTop($('.toTop'));
//分类页头部搜索栏点击出现下拉的搜索提示
classifyHeadInp.focus(function(){
    if($('#all_xiala li').html() != undefined){
        $(this).siblings('.search-tips').show();
    }
});
//背景搜索
beijinTopInp.focus(function(){
    if($('#xiala li').html() != undefined){
        $(this).siblings('.search-tips-bj').show();
    }
});
//搜索页顶部
searchInp.focus(function(){
    if($('#xiala-header li').html() != undefined){
        $(this).siblings('.float-search-tips').show();
    }
});

//分类页（企业办公这类的）顶部导航栏下方搜索栏点击出现下拉的搜索提示
officeTopInp.focus(function(){
    if($('.all_xiala li').html() != undefined) {
        $(this).siblings('.search-tips').show();
    }
});

//浮动header搜索点击下拉提示列表
floadHeadInp.focus(function(){
    if($('.float-search-tips li').html() != undefined){
        $(this).siblings('.float-search-tips').show();
    }
});
//控制顶部悬浮导航栏的出现和隐藏
var qFloatHead;
$('.pb-float-head').each(function(i,ele){
    var ele = $(ele)
    if (!ele.hasClass('header')) {
        qFloatHead = ele;
    }
});
if(qFloatHead){
        qFloatHead.display = false;
    $(document).scroll(function(){
        if($(this).scrollTop() > 250) {
            if (qFloatHead.display) return;
            qFloatHead.show();
            qFloatHead.display = true;
        }else {
            if (qFloatHead.display) {
                qFloatHead.hide();
                qFloatHead.display = false;
            }
        }
    });
}
// 点击搜索框之外的地方隐藏搜索提示面板
$(document).click(function(ev){
    var current = $(ev.target);
    var hideClssifySearchTips = false;
    var hideFloatSearchTips = false;
    var hideHomeSearchBanner = false;
    var hideOfficeSearchBanner = false;
    // 最多查5层，判断是否是再搜索框内点击的 
    for(var i = 0; i < 7; i++) {
        if(current.hasClass('search-input')) {
            hideClssifySearchTips = true;
            break;
            
        }else if (current.hasClass('float-search-input')){
            hideFloatSearchTips = true;
            break;
        }
        else if (current.hasClass('home-search-wrap')){
            hideHomeSearchBanner = true;
            break;
        }else if(current.hasClass('search-wrap')){
            hideOfficeSearchBanner = true;
            break;
        }
        else {
            current =current.parent();
        }
    }
    if (!hideClssifySearchTips) {
        $('.pb-head-classify .search-tips').hide();
    }
    if (!hideFloatSearchTips) {
        $('.pb-float-head .float-search-tips').hide();
    }
    if(!hideHomeSearchBanner) {
        $('.home .search-tips-bannner').hide();
    }
    if(!hideOfficeSearchBanner) {
        $('.classify-banner .search-tips').hide();
    }
});
//回到顶部
function backToTop(obj,time){
    time ? time : 800;
    obj.click(function(time){
        $('html,body').animate({
            scrollTop: 0
        }, time);
    });
}

window.onresize = function(){
    initHoverLine();
}
/*
 * 导航栏hover上去得小横线
 */
 initHoverLine();
function initHoverLine(){
    if ($('.pb-nav .nav>ul>.nav-item').length > 0) {
        var pbNavWrap = $('.pb-nav .nav-wrap');
        var pbNavItems = $('.pb-nav .nav>ul>.nav-item');
        var pbNavLine = $('.pb-nav .nav-wrap .hoverLine-wrap>.hoverLine');
        var pbNavMoreItemWrap = $('.pb-nav .nav>ul>.nav-item-more');
        var navMoreItems = $('.pb-nav .nav-item-more .more-item');
        var pbNavOffsetLeft = $('.pb-nav').offset().left;
        pbNavItems.each(function(i,ele){
            var ele = $(ele);
            var that = $(this);
            var $width = that.width();
            var dis = 47;
            if (window.innerWidth <= 1680) dis = 34;
            var $left = that.offset().left - pbNavOffsetLeft -1 + dis;
            if(i == 0) {
                $width += dis;
                $left -= dis;
            };
            if(ele.hasClass('left-two')) $left -= 1;
            if(ele.hasClass('nav-item-more')) $left += 1;
            ele.hover(function(){
                
                pbNavLine.css({
                    width: $width-dis*2,
                    'opacity':1
                });
                pbNavLine.stop(false,true);
                pbNavLine.animate({
                    left: $left
                }, 300);
            });
        });
        navMoreItems.each(function(i,ele){
            var ele = $(ele);
            var line = ele.find('.hoverline');
            ele.hover(function(ev){
            if($(ev.target).hasClass('hoverline-wrap') || $(ev.target).hasClass('hoverline')) return;
            var that = $(this);
            var parentLfet = that.parent().offset().left;    
            
            var word = that.find('>a>span');
            var $width = word.width();
            var $left = word.offset().left - parentLfet -1;
            line.stop(false,true);
            line.animate({
                    width: $width,
                    left: $left
                }, 300);
            },function(){
                line.animate({
                    width: 0,
                    left: 0
                }, 300);
            });
        });
        pbNavWrap.mouseleave(function(){
            pbNavLine.css({
                left: 0,
                width: 0
            });
        });
        pbNavMoreItemWrap.mouseleave(function(){
            pbNavLine.css({
                left: 0,
                width: 0
            });
        });
    }

    //分类页和搜索页更多按钮的出现与隐藏
    if($('.more-btn').length > 0) {
        $('.more-btn').each(function(i,ele){
            $this = $(this);
            var wrap = $this.siblings('.right-wrap');
            var childrens = wrap.children();
            var total = 0;
            childrens.each(function(i,ele){
                total += $(this).outerWidth(true);
            })
            if (total > wrap.width()) {
                $this.show();
            }else {
                $this.hide();
            }
        })
    }

}

//办公页的搜索框选项卡
if($('.office .search-modes').length > 0) {
    var searchModes = $('.office .search-modes>a');
    searchModes.click(function(){
        searchModes.each(function(i,ele){
            $(ele).removeClass('active');
        })
        $(this).addClass('active');
    });
}
//搜索页，广告业展开更多标签的按钮
if ($('.all-classify .more-btn').length > 0) {
    var moreBtn = $('.all-classify .more-btn');
    var classifyWrap =  $('.all-classify .right-wrap');
    moreBtn.get(0).onOff = false;  //false为收起状态
    classifyWrap.css('height',38);
    moreBtn.click(function(){
        var classifyWrap = $(this).prev('.right-wrap');
        var more = $(this).find('.more');
        if(this.onOff) {
            classifyWrap.css('height',38);
            more.text('更多')
            $(this).find('>i').css('transform','rotate(0)');
        }else {
            classifyWrap.get(0).style.cssText = '';
            more.text('收起')
            $(this).find('>i').css('transform','rotate(180deg)');
        }
        this.onOff = !this.onOff;
    });
}
if ($('.userwant-wrap .more-btn').length > 0) {
    var moreBtn = $('.userwant-wrap .more-btn');
    var classifyWrap =  $('.userwant-wrap .right-wrap');
    moreBtn.get(0).onOff = false;  //false为收起状态
    classifyWrap.css('height',24);
    moreBtn.click(function(){
        var classifyWrap = $(this).prev('.right-wrap');
        var more = $(this).find('.more');
        if(this.onOff) {
            classifyWrap.css('height',24);
            more.text('更多')
            $(this).find('>i').css('transform','rotate(0)');
        }else {
            classifyWrap.get(0).style.cssText = '';
            more.text('收起')
            $(this).find('>i').css('transform','rotate(180deg)');
        }
        this.onOff = !this.onOff;
    });
}
//弹窗关闭
if($('.pop .pop-close').length > 0){
    $('.pop .pop-close').click(function(ev){
		ev.cancelBubble = true;
        $(this).parents('.pop').hide();
		return false;
    });
}
//详情页蜘蛛搜索
if($('.g-rank-list').length > 0){
    var qRankNav = $('.rank-nav-item');
    var qRankList = $('.g-rank-list');
    qRankNav.click(function() {
        var that = this;
        qRankNav.each(function(i, ele) {
            if (ele == that) {
                $(ele).addClass('active');
                qRankList.each(function(index, ele) {
                    if (index == i) {
                        $(ele).show();
                    } else {
                        $(ele).hide();
                    }
                });
            } else {
                $(ele).removeClass('active');
            }
        })
    });
}

//热门活动的小包子动效
$(window).load(function() {
    var hotAct = $('.hot-act');
    hotAct.addClass('move');
    setTimeout(function(){
        hotAct.removeClass('move');
    },500)
})
$('.hot-act .icon-iconfontclose').click(function(){
    $(this).parent().hide();
    return false;
});

    
/**************************************** 分页类头部小搜索框JS ******************************************/
/**
 * 统计点击位置
 */
function tj_keyword(){
    var sort = $('#sort').val()
    $.ajax({
        type: 'POST',
        url: InitURL.AJAX+'/?m=search&a=index',
        data: {sort:sort},
        dataType: 'json',
        success: function (rs) {
        }
    });
}
function cookie(name) {
    var cookieArray = document.cookie.split("; ");
    var cookie = new Object();
    for (var i = 0; i < cookieArray.length; i++) {
        var arr = cookieArray[i].split("=");
        if (arr[0] == name) return unescape(arr[1]);
    }
    return "";
}

$(".login").on('click',function(){
   /* window.location.href="/login";*/
    _login()
})

$(".register").on('click',function(){
   /* window.location.href="/register";*/
    _reg()
})

function _login(){
    $(".login-pop").show();
}

function _reg(){ 
    $(".reg-pop").show();
}

$('#agree').on('click',function () {
    if($('#agree').is(':checked')) {
        $('.login-box').removeClass('ban')
        $('.agree-tips').hide()
    }else{
        $('.login-box').addClass('ban')
    }
})
//账号登录显示
$(".zhanghaologin").on('click',function(){
    $(".login-zhanghao").show();
})
//账号注册显示
$(".zhanghaoreg").on('click',function(){
    $('.re-popbox').hide();
	$(".reg-zhanghao").show();
})
$('.qq-btn').on('click',function () {
    if($('#agree').is(':checked')) {
        window.location.href='/qqLogin/index.php';
    }else{
        $('.agree-tips').show()
    }
})

//zhifubao
$("#zhifubao").on('click',function(){
	var zhi = $(this).attr('value');
	$("input[name='paytype']").attr('value',zhi);
	$('#weixin').removeClass('xuanze');
	$(this).addClass('xuanze');
	$('#zhifuxuanze').text('支付宝支付');
	if( paytype == "" ){
	    alert('请选择支付方式'); 
		return false
    }
	else{
		$("form").submit();
	}
})
//weixin
$("#weixin").on('click',function(){
	var zhi = $(this).attr('value');
	$('#zhifubao').removeClass('xuanze');
	$("input[name='paytype']").attr('value',zhi);
	$(this).addClass('xuanze');
	$('#zhifuxuanze').text('微信支付');
	if( paytype == "" ){
	    alert('请选择支付方式'); 
		return false
    }
	else{
		$("form").submit();
	}
})

//zhifuxuanze
$("#zhifuxuanze").on('click',function(){
	var paytype = $("input[name='paytype']").val();
	if( paytype == "" ){
	    alert('请选择支付方式'); 
		return false
    }
	else{
		$("form").submit();
	}
})


/**
 * 登录网站
 */
$(".querendenglu").on('click',function(){
    var fmdo = $("input[name='fmdo']").val();
	var dopost = $("input[name='dopost']").val();
	var keeptime = $("input[name='keeptime']").val();
	var userid = $("input[name='userid']").val();
	var pwd = $("input[name='pwd']").val();
	var tips = $('.collect-tips');
	tips.hide();
	$.ajax({
		url: '/member/userlogin.php',
        data: {
				fmdo: fmdo,
				myset: 'ajax',
				dopost: dopost,
				keeptime: keeptime,
				userid: userid,
				pwd: pwd
			},
        dataType: 'json',
        success:function(r){
		   var random = Math.random();
					tips.attr('flag',random);
		   if(r.son=="ok"){
			    $('.re-popbox').hide();
				tips.html('登录成功,即将为你刷新自动登录');
				tips.fadeIn(200);
				setTimeout(function(){
						location.reload()
					}, 500)
           }else{
			   
				$("#tishi").text(r.msg).show(1).delay(2000).hide(1); 
				tips.html(r.msg);
				tips.fadeIn(200);
           }
		   setTimeout(function(){
						if(tips.is(':visible') && tips.attr('flag')==random){
							tips.hide();
						}
					},1500);
	    }
	})
})
/**
 * 退出登录
 */
$(".tuichudenglu").on('click',function(){
	var tips = $('.collect-tips');
	tips.hide();
	$.ajax({
		url: '/member/userlogin.php',
        data: {
				fmdo: 'login',
				myset: 'ajax',
				dopost: 'exit'
			},
        dataType: 'json',
        success:function(r){
		   var random = Math.random();
					tips.attr('flag',random);
		   if(r.son=="exit"){
			    $('.re-popbox').hide();
				tips.html('成功退出账号,即将为你刷新');
				tips.fadeIn(200);
				setTimeout(function(){
						location.reload()
					}, 500)
           }else{
			   
				tips.html('退出失败');
				tips.fadeIn(200);
           }
		   setTimeout(function(){
						if(tips.is(':visible') && tips.attr('flag')==random){
							tips.hide();
						}
					},1500);
	    }
	})
})
/**
 * 登录账号注册
 */
$(".querenzhuce").on('click',function(){
    var fmdo = $("input[name='fmdo1']").val();
	var user_name = $("input[name='user_name']").val();
	var user_pass = $("input[name='user_pass']").val();
	var user_pass2 = $("input[name='user_pass2']").val();
	var yanzhengma = $("input[name='yanzhengma']").val();
	var dxyzm = $("input[name='dxyzm']").val();
	var shouji = $("input[name='shouji']").val();
	var tips = $('.collect-tips');
	tips.hide();
	$.ajax({
		url: '/member/userlogin.php',
        data: {
				fmdo: fmdo,
				step: '1',
				myset: 'ajax_reg',
				dopost: 'ajax_reg',
				user_name: user_name,
				user_pass: user_pass,
				user_pass2: user_pass2,
				dxyzm: dxyzm,
				shouji: shouji,
				yanzhengma: yanzhengma
			},
        dataType: 'json',
        success:function(r){
		   var random = Math.random();
					tips.attr('flag',random);
		   if(r.son=="ok"){
			    $('.reg-zhanghao').hide();
				tips.html('恭喜您,注册成功!');
				tips.fadeIn(200);
           }else{
			   
				$("#tishizhuce").text(r.msg).show(1).delay(2000).hide(1); 
				tips.html(r.msg);
				tips.fadeIn(200);
           }
		   setTimeout(function(){
						if(tips.is(':visible') && tips.attr('flag')==random){
							tips.hide();
						}
					},1500);
	    }
	})
})








//切换到登录
$(".reg-pop-dl").on('click',function(){
    $(".reg-pop").hide ();
    $('.login-box').removeClass('ban')
    $(".login-pop").show();
})
//切换到注册
$(".login-pop-dl").on('click',function(){
    $(".reg-pop").show ();
    $('.login-box').removeClass('ban')
    $(".login-pop").hide();
})
//发布帖子
$(".fabutiezi").on('click',function(){
	var tips = $('.collect-tips');
	$.ajax({
		url: '/plus/chaxunlogin.php',
        //data: {},
        dataType: 'json',
        success:function(r){
		   var random = Math.random();
					     tips.attr('flag',random);
		   if(r.status==0){
			    _login('登录网站', '登录后可发帖');
		        return false;
           }else if(r.status==1){
				var title = $("input[name='title']").val();
				var dopost = $("input[name='dopost']").val();
				var channelid = $("input[name='channelid']").val();
				var typeid = $("input[name='typeid']").val();
				var content = UE.getEditor('neirong').getContent();
				$.ajax({
		            url: '/member/fatiezi.php',
                    data: {
						  title : title,
						  dopost : dopost,
						  channelid : channelid,
						  typeid : typeid,
						  content : content
					},
                    dataType: 'json',
                    success:function(date){
						//alert(date)
						if(date.zhi=='ok'){	
                              $('.collect-tips').show();
							  tips.html(date.msg);
				              tips.fadeIn(200);
							  setTimeout(function(){
						location.reload()
					}, 500)
							 
                        }else{
							  tips.html(date.msg);
				              tips.fadeIn(200);
						}setTimeout(function(){
						if(tips.is(':visible') && tips.attr('flag')==random){
							tips.hide();
						}
					},1500);
				   
					}
				})

           }else{ 
				
           }
	    }
	})

										
    //alert(auth_uid);
})
//评论提交
$(".pingluntijiao").on('click',function(){
	var tips = $('.collect-tips');
	$.ajax({
		url: '/plus/chaxunlogin.php',
        //data: {},
        dataType: 'json',
        success:function(r){
		   var random = Math.random();
					     tips.attr('flag',random);
		   if(r.status==0){
			    _login('登录网站', '登录后可评论');
		        return false;
           }else if(r.status==1){
				var aid = $("input[name='aid']").val();
				var content = UE.getEditor('neirong').getContent();
				$.ajax({
		            url: '/plus/pinglun.php',
                    data: {
						  aid : aid,
						  content : content
					},
                   //dataType: 'json',
                    success:function(zhi){
						if(zhi=='ok'){	
                              $('.collect-tips').show();
							  tips.html('评论成功，请耐心等待管理审核！');
				              tips.fadeIn(200);
							  setTimeout(function(){
						location.reload()
					}, 500)
							 
                        }else{
							  tips.html('评论失败,请联系客服');
				              tips.fadeIn(200);
						}setTimeout(function(){
						if(tips.is(':visible') && tips.attr('flag')==random){
							tips.hide();
						}
					},1500);
				   
					}
				})

           }else{ 
				
           }
	    }
	})

										
    //alert(auth_uid);
})
//提现申请
$("#tixian").on('click',function(){
    var zhifubao = $("input[name='alipay']").val();
	var xingming = $("input[name='xingming']").val();
	var phone = $("input[name='phone']").val();
	var money = $("input[name='money']").val();
	var tips = $('.collect-tips');
	if( zhifubao == "" ){
	    $("#tixiantishi").text('请输入支付宝账号').show(1).delay(2000).hide(1); 
		return false
    }else if( xingming == "" ){
	    $("#tixiantishi").text('请输入支付宝姓名').show(1).delay(2000).hide(1); 
		return false
    }else if( phone == "" ){
	    $("#tixiantishi").text('请输入手机号').show(1).delay(2000).hide(1); 
		return false
    }else if( money < 50 ){
	    $("#tixiantishi").text('余额大于50才能提现哦').show(1).delay(2000).hide(1); 
		return false
    }else{
	    $.ajax({
		     url: '/member/ajax_tixian.php',
             type: 'POST',
             data: {
			     zhifubao : zhifubao,
				 xingming : xingming,
				 money    : money,
				 phone      : phone
		     },
             //dataType: 'json',
             success:function(zhi){
		      
		        var random = Math.random();
					tips.attr('flag',random);
		        if(zhi=="ok"){
			        $('.re-popbox').hide();
				    tips.html('申请成功，请耐心等待');
				    tips.fadeIn(200);
				    setTimeout(function(){
						    window.location.href='/member/tixianlist.php';
					}, 500)
                }else{
				    tips.html('申请失败，详情请联系客服');
				    tips.fadeIn(200);
                }
		   setTimeout(function(){
						if(tips.is(':visible') && tips.attr('flag')==random){
							tips.hide();
						}
					},1500);
	      }
	   })
	
	 }
})
//总换youhui
$("#zonghuan").on('click',function(){
    var cardid = $("input[name='cardid']").val();
	var tips = $('.collect-tips');
	if( cardid == "" ){
	    $("#zonghuantishi").text('请输入总换码').show(1).delay(2000).hide(1); 
		return false
    }else{
	    $.ajax({
		     url: '/member/check_card.php',
             type: 'POST',
             data: {
			     cardid : cardid
		     },
             dataType: 'json',
             success:function(date){
		      
		        var random = Math.random();
					tips.attr('flag',random);
		        if(date.zhi=="ok"){
			        $('.re-popbox').hide();
				    tips.html(date.msg);
				    tips.fadeIn(200);
				    setTimeout(function(){
						    window.location.href='/member/zonghuan.php';
					}, 500)
                }else{
				    tips.html(date.msg);
				    tips.fadeIn(200);
                }
		   setTimeout(function(){
						if(tips.is(':visible') && tips.attr('flag')==random){
							tips.hide();
						}
					},1500);
	      }
	   })
	
	 }
})

//总换jifen
$("#zonghuanjifen").on('click',function(){
    var money = $("input[name='money']").val();
	var tips = $('.collect-tips');
	if( money == "" ){
	    $("#zonghuanjifentishi").text('请输入总换金额').show(1).delay(2000).hide(1); 
		return false
    }else{
	    $.ajax({
		     url: '/member/jf.php',
             type: 'POST',
             data: {
			     money : money,
				 dopost : 'jifen'
		     },
             dataType: 'json',
             success:function(date){
		      
		        var random = Math.random();
					tips.attr('flag',random);
		        if(date.zhi=="ok"){
			        $('.re-popbox').hide();
				    tips.html(date.msg);
				    tips.fadeIn(200);
				    setTimeout(function(){
						    window.location.href='/member/jf.php';
					}, 500)
                }else{
				    tips.html(date.msg);
				    tips.fadeIn(200);
                }
		   setTimeout(function(){
						if(tips.is(':visible') && tips.attr('flag')==random){
							tips.hide();
						}
					},1500);
	      }
	   })
	
	 }
})
//切换shoujihaokuang
$("#shoujixiugai").on('click',function(){
	$("#yyzzmm").show();
	$("#shoujixiugai").hide();
	$("#btnSendCode").show();
	$("input[name='shouji']").attr('value','');
	$("input[name='shouji']").removeAttr('disabled');
	$("input[name='shouji']").attr('placeholder','请输入新的手机号码');
	//$(this).text()=="修改" ? $(this).text("不修改") : $(this).text("修改");	
})

//shoujixiugai
$("#querenshoujixiugai").on('click',function(){
    var shouji = $("input[name='shouji']").val();
	var dxyzm = $("input[name='dxyzm']").val();
	var yanzhengma = $("input[name='yanzhengma']").val();
	
	var tips = $('.collect-tips');
	if( shouji == "" ){
	    $("#xiugaiziliaotishi").text('请输入新的手机号码').show(1).delay(2000).hide(1); 
		return false
    }else if( yanzhengma == "" ){
	    $("#xiugaiziliaotishi").text('请输入短信验证码').show(1).delay(2000).hide(1); 
		return false
    }else{
	    $.ajax({
		     url: '/member/dxyz.php',
             type: 'POST',
             data: {
			     dopost : 'yanzheng',
				 shouji : shouji,
				 dxyzm : dxyzm,
				 yanzhengma : yanzhengma
		     },
             dataType: 'json',
             success:function(date){
		        //alert(date)
		        var random = Math.random();
					tips.attr('flag',random);
		        if(date.zhi=="ok"){
			        $('.re-popbox').hide();
				    tips.html(date.msg);
				    tips.fadeIn(200);
				    setTimeout(function(){
						    window.location.href='/member/xiugai.php';
					}, 500)
                }else{
				    tips.html(date.msg);
				    tips.fadeIn(200);
                }
		   setTimeout(function(){
						if(tips.is(':visible') && tips.attr('flag')==random){
							tips.hide();
						}
					},1500);
	      }
	   })
	
	 }
})

//xiugaiziliao
$("#xiugaiziliao").on('click',function(){
    var uname = $("input[name='uname']").val();
	var oldpwd = $("input[name='oldpwd']").val();
	var password = $("input[name='password']").val();
	var userpwdok = $("input[name='userpwdok']").val();
	var tips = $('.collect-tips');
	if( uname == "" ){
	    $("#xiugaiziliaotishi").text('请输入昵称').show(1).delay(2000).hide(1); 
		return false
    }else if( oldpwd == "" ){
	    $("#xiugaiziliaotishi").text('请输入原来的密码').show(1).delay(2000).hide(1); 
		return false
    }else{
	    $.ajax({
		     url: '/member/xiugai.php',
             type: 'POST',
             data: {
			     dopost : 'save',
				 uname : uname,
				 oldpwd : oldpwd,
				 password : password,
				 userpwdok : userpwdok
		     },
             dataType: 'json',
             success:function(date){
		        //alert(date)
		        var random = Math.random();
					tips.attr('flag',random);
		        if(date.zhi=="ok"){
			        $('.re-popbox').hide();
				    tips.html(date.msg);
				    tips.fadeIn(200);
				    setTimeout(function(){
						    window.location.href='/member/xiugai.php';
					}, 500)
                }else{
				    tips.html(date.msg);
				    tips.fadeIn(200);
                }
		   setTimeout(function(){
						if(tips.is(':visible') && tips.attr('flag')==random){
							tips.hide();
						}
					},1500);
	      }
	   })
	
	 }
})
//xiugaikongjian
$("#xiugaikongjian").on('click',function(){
    var spacename = $("input[name='spacename']").val();
	var sign = $("input[name='sign']").val();
	var tips = $('.collect-tips');
	if( spacename == "" ){
	    $("#xiugaiziliaotishi").text('请输入空间名称').show(1).delay(2000).hide(1); 
		return false
    }else if( sign == "" ){
	    $("#xiugaiziliaotishi").text('请输入个性签名').show(1).delay(2000).hide(1); 
		return false
    }else{
	    $.ajax({
		     url: '/member/kongjian.php',
             type: 'POST',
             data: {
			     dopost : 'save',
				 spacename : spacename,
				 sign : sign
		     },
             dataType: 'json',
             success:function(date){
		        //alert(date)
		        var random = Math.random();
					tips.attr('flag',random);
		        if(date.zhi=="ok"){
			        $('.re-popbox').hide();
				    tips.html(date.msg);
				    tips.fadeIn(200);
				    setTimeout(function(){
						    window.location.href='/member/kongjian.php';
					}, 500)
                }else{
				    tips.html(date.msg);
				    tips.fadeIn(200);
                }
		   setTimeout(function(){
						if(tips.is(':visible') && tips.attr('flag')==random){
							tips.hide();
						}
					},1500);
	      }
	   })
	
	 }
})
//xiugaitouxiang
$("#xiugaitouxiang").on('click',function(){
    var face = $("input[name='face']").val();
	
	var tips = $('.collect-tips');
	if( face == "" ){
	    $("#xiugaitouxiangtishi").text('请从本地选择头像文件').show(1).delay(2000).hide(1); 
		return false
    }else{
	    $.ajax({
		     url: '/member/touxiang.php',
             type: 'POST',
             data: {
			     dopost : 'save',
				 face : face
		     },
             dataType: 'json',
             success:function(date){
		        //alert(date)
		        var random = Math.random();
					tips.attr('flag',random);
		        if(date.zhi=="ok"){
			        $('.re-popbox').hide();
				    tips.html(date.msg);
				    tips.fadeIn(200);
				    setTimeout(function(){
						    window.location.href='/member/touxiang.php';
					}, 500)
                }else{
				    tips.html(date.msg);
				    tips.fadeIn(200);
                }
		   setTimeout(function(){
						if(tips.is(':visible') && tips.attr('flag')==random){
							tips.hide();
						}
					},1500);
	      }
	   })
	
	 }
})

//renzheng
$("#renzheng").on('click',function(){
    var xingming = $("input[name='xingming']").val();
	var shouji = $("input[name='shouji']").val();
	var sfzhm = $("input[name='sfzhm']").val();
	var shenfenzheng = $("input[name='shenfenzheng']").val();
	
	var tips = $('.collect-tips');
	if( xingming == "" ){
	    $("#renzhengtishi").text('请输入真实姓名').show(1).delay(2000).hide(1); 
		return false
    }else if( shouji == "" ){
	    $("#renzhengtishi").text('请输入手机号码').show(1).delay(2000).hide(1); 
		return false
    }else if( sfzhm == "" ){
	    $("#renzhengtishi").text('请输入身份证号码').show(1).delay(2000).hide(1); 
		return false
    }else if( shenfenzheng == "" ){
	    $("#renzhengtishi").text('请上传身份证正面照片').show(1).delay(2000).hide(1); 
		return false
    }else{
	    $.ajax({
		     url: '/member/renzheng.php',
             type: 'POST',
             data: {
			     dopost : 'save',
				 xingming : xingming,
				 shouji : shouji,
				 sfzhm : sfzhm,
				 shenfenzheng : shenfenzheng
		     },
             dataType: 'json',
             success:function(date){
		        //alert(date)
		        var random = Math.random();
					tips.attr('flag',random);
		        if(date.zhi=="ok"){
			        $('.re-popbox').hide();
				    tips.html(date.msg);
				    tips.fadeIn(200);
				    setTimeout(function(){
						    window.location.href='/member/renzheng.php';
					}, 500)
                }else{
				    tips.html(date.msg);
				    tips.fadeIn(200);
                }
		   setTimeout(function(){
						if(tips.is(':visible') && tips.attr('flag')==random){
							tips.hide();
						}
					},1500);
	      }
	   })
	
	 }
})


function yijiantijiao(){
    $(".new-feedback").show();
}
//yijian
$("body").delegate('.new-feedback>.feedback>.submit-btn', 'click', function(){
    var $this = $(this);
	var flag = $this.attr('flag');
	if (flag=='1') {
		var baoguiyijian = $.trim($('textarea[name=baoguiyijian]').val());
		var baoguiqq = parseInt($('textarea[name=baoguiqq]').val());
	}	
	var tips = $('.collect-tips');
	if( baoguiyijian == "" ){
	    alert('请填写您的意见');
		return false
    }else if( baoguiqq == "" ){
	    alert('请填写您的qq');
		return false
    }else{
	    $.ajax({
		     url: '/plus/yijian.php',
             type: 'POST',
             data: {
				 baoguiyijian : baoguiyijian,
				 baoguiqq : baoguiqq
		     },
             dataType: 'json',
             success:function(date){
		        //alert(date)
		        var random = Math.random();
					tips.attr('flag',random);
		        if(date.zhi=="ok"){
			        $(".new-feedback").remove();
					$('.re-popbox').hide();
				    tips.html(date.msg);
				    tips.fadeIn(200);
				    setTimeout(function(){
						    window.location();
					}, 500)
                }else{
				    tips.html(date.msg);
				    tips.fadeIn(200);
                }
		   setTimeout(function(){
						if(tips.is(':visible') && tips.attr('flag')==random){
							tips.hide();
						}
					},1500);
	      }
	   })
	
	 }
})


$(function() {
	 $('aside').load('http://ibaotu.com/?m=publicAjax&a=asideRight',function(){
		backToTop($('.toTop')); //回到顶部
	 });
     // 新版反馈-用户意见-字数限制
     $("body").delegate('.new-feedback>.feedback>.bt-suggestion>#area', "input oninput", function() {
         var $this = $(this),
             _val = $this.val(),
             count = "";
         if (_val.length > 200) {
             $this.val(_val.substring(0, 200));
         }
         count = $this.val().length;
         $("#text-count").text(count + '/200');
     });
 })
//升级切换
$(".reg-pop-dl").on('click',function(){
    $(".reg-pop").hide ();
    $('.login-box').removeClass('ban')
    $(".login-pop").show();
})

var InterValObj;
var count = 10;
var curCount;//当前剩余秒数
function sendMessage() {
    var shouji = $("input[name='shouji']").val();
	var tips = $('.collect-tips');
	if( shouji == "" ){
	    alert('请输入正确的手机号码');
		return false
	}else{
		
		$.ajax({
     　　  type: "POST",
     　　   url: '/member/sms.php',
            data: {
				XDEBUG_SESSION_START: 'ECLIPSE_DBGP',
				mobile_phone : shouji
			},
			dataType: "json",　　 	
            success:function(date){
			    //alert(date)
				var random = Math.random();
					tips.attr('flag',random);
		        if(date.zhi=="ok"){
				    tips.html(date.msg);
				    tips.fadeIn(200);
					
					curCount = count;
　　                //设置button效果，开始计时
                    $("#btnSendCode").attr("disabled", "true");
                    $("#btnSendCode").val("" + curCount + "后重新获取");
		            InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次
				    
					$("input[name='dxyzm']").attr("value",date.yzm);
                }else{
				    tips.html(date.msg);
				    tips.fadeIn(200);
                }
		   setTimeout(function(){
						if(tips.is(':visible') && tips.attr('flag')==random){
							tips.hide();
						}
					},1500);　　
	        }
        });
	}                
}
//timer处理函数
function SetRemainTime() {
            if (curCount == 0) {                
                window.clearInterval(InterValObj);//停止计时器
                $("#btnSendCode").removeAttr("disabled");//启用按钮
                $("#btnSendCode").val("重新获取");
            }
            else {
                curCount--;
                $("#btnSendCode").val("" + curCount + "后重新获取");
            }
        }







function pop(status){
	$.get('http://ibaotu.com/?m=aboutus&a=feedback&status='+status,
		function(html) {
			//$('body').find('.new-feedback').remove();
			$('body').append(html);
		},'html'
	);
}

/*seo跳转*/
$('.jump-details-seo').on('click',function(){
    url = $(this).attr('seo-url')
    window.open(url)
})